ACTOR SFortBFG9000 : BFG9000 replaces BFG9000
{
  Height 20
  Weapon.SelectionOrder 25
  Weapon.AmmoUse 40
  Weapon.AmmoGive 40
  Weapon.AmmoType "Cell"
  +WEAPON.NOLMS
  +WEAPON.ALLOW_WITH_RESPAWN_INVUL
  -WEAPON.NOAUTOFIRE
  +WEAPON.NOAUTOAIM
  Inventory.PickupMessage "$GOTBFG9000"
  Tag "BFG9000"
  States
  {
  Ready:
    BFGG A 1 A_WeaponReady
    Loop
  Deselect:
    BFGG A 0 A_Lower
    Loop
  Select:
    BFGG A 1 A_Raise
    Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth9",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth8",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth7",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth6",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth5",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth4",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth3",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth2",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth1",1,"CheckInvis")
  DelInvis:
	TNT1 A 0 A_TakeInventory("PowerGhostStealth9",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth8",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth7",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth6",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth5",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth4",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth3",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth2",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth1",1)
  FireNormal:
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
    BFGG A 20 A_BFGSound
    BFGG B 10 A_GunFlash
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
    BFGG B 10 A_FireBFG
    BFGG B 20 A_ReFire
    Goto Ready
  CheckInvis:
	TNT1 A 0 A_PlaySound("misc/ghoststealth",CHAN_5)
	Goto DelInvis
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	Goto FireNormal+4
  AltFire:
	TNT1 A 0 A_JumpIfInventory("Cell",600,"AltLoad")
	TNT1 A 0 ACS_NamedExecuteAlways("BFGAltCell",0)
	BFGG A 20 A_Playsound("weapons/bfgfail",CHAN_WEAPON)
	TNT1 A 0 A_Refire("AltFire")
	Goto Ready
  AltLoad:
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
	TNT1 A 0 A_GiveInventory("PowerBFGSlower",1)
	BFGG A 20 A_Playsound("weapons/bfgfail",CHAN_WEAPON)
    BFGG B 5 A_PlaySound("weapons/bfgf2",CHAN_WEAPON)
	BFGG ABA 5
    BFGG B 5 A_GunFlash
	BFGG AB 5
	TNT1 A 0 A_JumpIfInventory("Cell",600,"AltSuccess")
	Goto AltFire+1
  AltSuccess:
    TNT1 A 0 A_TakeInventory("Cell",600)
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"AltQuad")
    BFGG B 5 A_FireCustomMissile("SFortBFGBall2",0,0)
	BFGG C 35
	BFGG C 35 A_TakeInventory("PowerBFGSlower",1)
    Goto Ready
  AltQuad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	Goto AltSuccess+2
  Flash:
    BFGF A 11 Bright A_Light1
    BFGF B 6 Bright A_Light2
    Goto LightDone
  Spawn:
    BFUG A -1
    Stop
  }
}

ACTOR SFortBFGBall : BFGBall replaces BFGBall
{
  Speed 25
  SeeSound "weapons/bfgball"
  DamageType "BFG"
  SelfObituary "%o self-splintered with %p BFG."
  +EXTREMEDEATH
  States
  {
  Death:
    BFE1 A 8 Bright A_Explode(160,160)
    BFE1 B 8 Bright
    BFE1 C 8 Bright A_BFGSpray("SFortBFGExtra",40,15)
    BFE1 DEF 8 Bright
    Stop
  }
}

ACTOR SFortBFGBall2 : SFortBFGBall
{
  Speed 25
  Damage 400
  Radius 26
  Height 16
  Scale 2.0
  ProjectileKickBack 5000
  SeeSound "weapons/bfgball2"
  DeathSound "weapons/bfgx2"
  SelfObituary "%o self-splintered with %p own BFG."
  +RIPPER
  +EXTREMEDEATH
  States
  {
  Spawn:
    BFS1 AB 4 Bright A_CustomMissile("SFortBFGBall",8,0,random(0,359),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(0,359))
    Loop
  Death:
    BFE1 A 8 Bright A_Explode(320,320)
	BFE1 B 8 Bright
    BFE1 C 8 Bright A_BFGSpray("SFortBFGExtra",40,15)
    BFE1 DEF 8 Bright
    Stop
  }
}

ACTOR SFortBFGExtra : BFGExtra
{
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_GiveInventory("SFortSpam",1,AAPTR_DEFAULT)
      BFE2 A 8 Bright A_PlaySound("weapons/bfgray",CHAN_VOICE)
	  BFE2 BCD 8 Bright
      Stop
	}
}

ACTOR SFortBFG10K : BFG10K replaces BFG10K
{
  Weapon.AmmoUse 5
  Weapon.SelectionOrder 25
  Tag "BFG10K"
  DamageType "BFG"
  +WEAPON.NOLMS
  +WEAPON.ALLOW_WITH_RESPAWN_INVUL
  +WEAPON.NOAUTOAIM
  States
  {
  Deselect:
    BG2G E 0 A_Lower
    Loop
  Select:
    BG2G E 1 A_Raise
    Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth9",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth8",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth7",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth6",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth5",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth4",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth3",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth2",1,"CheckInvis")
	TNT1 A 0 A_JumpIfInventory("PowerGhostStealth1",1,"CheckInvis")
  DelInvis:
	TNT1 A 0 A_TakeInventory("PowerGhostStealth9",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth8",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth7",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth6",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth5",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth4",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth3",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth2",1)
	TNT1 A 0 A_TakeInventory("PowerGhostStealth1",1)
  FireNormal:
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
    BG2G E 20 A_PlaySound("weapons/bfg10kf",CHAN_WEAPON)
    BG2G F 4
    BG2G G 1
    BG2G H 1
    BG2G I 1
    BG2G J 1
    Goto Hold
  Hold:
	BG2G K 2 Bright A_GunFlash
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	TNT1 A 0 A_PlaySound("weapons/bfg10kf2",CHAN_6)
	BG2G L 2 Bright A_FireBullets(0,0,1,0,"BFG10kShot")
	BG2G M 2 Bright
	TNT1 A 0 A_ReFire
	BG2G O 35 A_PlaySound("weapons/bfg10kcool",CHAN_WEAPON)
	Goto Ready
  CheckInvis:
	TNT1 A 0 A_PlaySound("misc/ghoststealth",CHAN_5)
	Goto DelInvis
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg2",CHAN_7)
	Goto Hold+2
  AltFire:
	TNT1 A 0 A_JumpIfInventory("Cell",600,"AltLoad")
	TNT1 A 0 ACS_NamedExecuteAlways("BFGAltCell",0)
	BG2G O 20 A_Playsound("weapons/bfgfail",CHAN_WEAPON)
	TNT1 A 0 A_Refire("AltFire")
	Goto Ready
  AltLoad:
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
	TNT1 A 0 A_GiveInventory("PowerBFGSlower",1)
    TNT1 A 0 A_Playsound("weapons/bfgfail",CHAN_WEAPON)
	BG2G ABCD 3
    BG2G E 11 Bright A_PlaySound("weapons/beegchr",CHAN_WEAPON)
    BG2G FGHIJK 4 Bright
	TNT1 A 0 A_JumpIfInventory("Cell",600,"AltSuccess")
	TNT1 A 0 ACS_NamedExecuteAlways("BFGAltCell",0)
	BG2G O 20 A_Playsound("weapons/bfgfail",CHAN_WEAPON)
	Goto Ready
  AltSuccess:
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"AltQuad")
	TNT1 A 0 A_PlaySound("weapons/beegfire",CHAN_WEAPON)
    TNT1 A 0 A_TakeInventory("Cell",600)
	TNT1 A 0 A_GunFlash("AltFlash")
	TNT1 AAAAAAAAAA 0 A_RailAttack(500,random(-5,5),0,None,"Green",RGF_FULLBRIGHT,10,None,0,0,8192,35,1.0,4.0,None,random(-5,5))
	BG2G L 5 Bright A_FireCustomMissile("SFortBFG10KBall",0,0)
	BG2G M 5 Bright
	BG2G N 5 Bright
	BG2G O 35 A_PlaySound("weapons/bfg10kcool",CHAN_AUTO)
	TNT1 A 0 A_TakeInventory("PowerBFGSlower",1)
	Goto Ready
  AltQuad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	Goto AltSuccess+2
  AltFlash:
    TNT1 A 10 A_Light2
    TNT1 A 10 A_Light1
	Goto LightDone
  }
}

ACTOR SFortBFG10KBall : FastProjectile
{
  Damage 500
  Radius 13
  Height 8
  Speed 1000
  Scale 2.0
  RenderStyle Add
  Alpha 0.75
  Projectile
  ProjectileKickBack 5000
  SeeSound "weapons/bfgball2"
  DeathSound "weapons/bfgx2"
  Obituary "%o was blasted by %k's BFG10K."
  SelfObituary "%o got reckless with %p BFG10K."
  +RANDOMIZE
  +EXTREMEDEATH
  States
  {
  Spawn:
    BFS1 AB 4 Bright
    Loop
  Death:
    BFE1 A 4 Bright A_Explode(320,320,0)
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
    BFE1 A 4 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
	BFE1 B 2 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
	BFE1 B 2 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
	BFE1 B 2 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
	BFE1 B 2 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
    BFE1 C 4 Bright A_BFGSpray("SFortBFGExtra",40,15)
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
    BFE1 C 4 Bright
	TNT1 AAA 0 A_CustomMissile("SFortBFGBall3",8,0,random(120,240),CMF_AIMDIRECTION|CMF_TRACKOWNER,random(-10,10))
    BFE1 DEF 8 Bright
    Stop
  }
}

ACTOR SFortBFGBall3 : SFortBFGBall
{
  Obituary "%o was obliterated by %k's BFG10K alt-fire."
  States
  {
  Death:
    BFE1 A 8 Bright A_Explode(160,160)
	BFE1 B 8 Bright
    BFE1 C 8 Bright A_BFGSpray("SFortBFGExtra",40,15)
    BFE1 DEF 8 Bright
    Stop
  }
}

ACTOR PowerBFGSlower : PowerSpeed
{
  Powerup.Duration 0x7FFFFFFF
  Speed 0.1
  +POWERSPEED.NOTRAIL
}

ACTOR SFortSpamChecker : CustomInventory
{
	+INVENTORY.AUTOACTIVATE
	-INVENTORY.INVBAR
	States
	{
	Pickup:
	  TNT1 A 0 ACS_NamedExecuteAlways("SpamRemover",0)
	  TNT1 A 0 A_JumpIfInventory("SFortSpam",1,"GiveMedal")
	  TNT1 A 0 A_GiveInventory("SFortSpam",1)
	  Stop
	GiveMedal:
	  TNT1 A 0 A_GivePlayerMedal("Spam",0)
	  Stop
	}
}

ACTOR SFortSpam : Inventory
{
	Inventory.MaxAmount 63
}